import { Controller, Get, Headers, ParseIntPipe, Query, SetMetadata, UseGuards } from '@nestjs/common';
import { AppService } from './app.service';
import { AaaGuard } from './aaa.guard';
import { Aaa } from './aaa.decorator';
import { Bbb } from './bbb.decorator';
import { MyHeaders } from './ccc.decorator';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  @SetMetadata('aaa','admin')
  @UseGuards(AaaGuard)
  getHello(): string {
    return this.appService.getHello();
  }

  @Get('hello')
  @Aaa('admin','abc')   //使用自定义装饰器
  @UseGuards(AaaGuard)  //使用某个守卫
  getHello2(){
    return this.appService.getHello();
  }

  //组合装饰器
  @Bbb('hello2','admin','bbb')
  getHello3(){
    return this.appService.getHello();
  }
   
  //自定义参数装饰器
  @Get('hello3')
  getHello4(@Headers('Accept') header1, @MyHeaders('Accept') header2){
    console.log('header1',header1);
    console.log('header2',header2);
  }

  @Get('hello4')
  getHello5(@Query('aaa',new ParseIntPipe()) aaa){
      console.log(aaa);
  }

}
